package com.wn.procurement.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wn.common.PageBean;
import com.wn.entity.Material;
import com.wn.procurement.mapper.MaterialMapper;
import com.wn.procurement.service.MaterialService;
import com.wn.procurement.vo.MaterialVo;
import com.wn.utils.PageBeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MaterialServiceImpl implements MaterialService {

    @Autowired
    private MaterialMapper materialMapper;

    @Override
    public void insert(Material material) {
        materialMapper.insert(material);
    }

    @Override
    public void update(Material material) {
        materialMapper.update(material);
    }

//    @Override
//    public PageBean<Material> getAll() {
//        return materialMapper.getAll();
//    }

    @Override
    public PageBean<Material> getByCondition(MaterialVo materialVo) {
        Page<Material> page = PageHelper.startPage(materialVo.getCurrPage(), materialVo.getPageSize());
        List<Material> list = materialMapper.getByCondition(materialVo.getMaterial());
        return PageBeanUtil.getPageBean(list,page,materialVo.getCurrPage(),materialVo.getPageSize());
    }

    @Override
    public List<Material> getMaterialBymaterialVo(MaterialVo materialVo) {
       return materialMapper.getByCondition(materialVo);
    }
}
